﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Library.Models;
using Library.Repository;
using Library.TwiCommunication;
using Library.Utils;
using log4net;

namespace Library.Wcf
{
    public class DeviceWcfService : IDeviceWcfService
    {
        private static readonly ILog Log = LogManager.GetLogger("DeviceWcfService");

        private IDeviceRepository deviceRepository;

        private ITwiCommunicator twiCommunicator;

        public DeviceWcfService()
        {
            deviceRepository = ServiceLocator.Instance.GetService<IDeviceRepository>();
        }

        public List<TwiDevice> GetAllWithData()
        {
            return deviceRepository.GetAllWithData();
        }

        public void WriteDevicePin(int address, int pin, bool value)
        {
            deviceRepository.WriteDevicePin(address, pin, value);
        }
    }



    [ServiceContract]
    public interface IDeviceWcfService
    {
        [OperationContract]
        List<TwiDevice> GetAllWithData();

        [OperationContract]
        void WriteDevicePin(int address, int pin, bool value);
    }
}
